/**
 * Info*E Task通用工具类
 * 
 * 主要用于构造where语句，添加发布状态等
 * 
 * @author 魏文杰 
 * @Version 1.0
 * @Date 2013-10-08
 */

package ext.generic.erp.task;

import java.util.Enumeration;

import wt.change2.ChangeOrder2;
import wt.part.WTPart;
import wt.part.WTPartMaster;
import wt.part.WTPartUsageLink;

import com.infoengine.SAK.Task;
import com.infoengine.object.factory.Group;

import ext.generic.erp.attributes.AttributeUtil;
import ext.generic.erp.attributes.PartUsageLinkAttribute;
import ext.generic.erp.bean.AlternativeMaterial;
import ext.generic.erp.util.IntegrationConstant;
import ext.generic.erp.util.PDMIntegrationLogUtil;
import ext.generic.erp.common.CommonPDMUtil;
import ext.generic.erp.common.CommonUtil;

public class IETaskCommonUtil {

	/*
	 * add by ningxuge
	 * 
	 * @reason 增加flag_crm，并未它赋初始值‘N’
	 */
	private static final String RELEASE_FLAG_CRM = "flag_crm";

	private static final String RELEASE_FLAG = "flag";

	private static final String RELEASE_DATE = "releaseDate";

	private static final String PDM_WRITE_BACK_STATUS = "pdmWritebackStatus";

	private static final String WCH_TASK_DIR = "tasks/";

	public static String clazz = IETaskCommonUtil.class.getName();

//	public static final String TASK_FILE_DIRECOTRY = (String) ERPPropertiesUtil.getInstance().readProperties().get(IntegrationConstant.TASK_DIRECTORY);
	public static final String TASK_FILE_DIRECOTRY = CommonPDMUtil.getWindchillPath() + WCH_TASK_DIR;

	/**
	 * 为Info*E Task添加发布状态值和发布时间值
	 * 
	 * @param task
	 */
	public static void addProcessStatus(Task task) {
		addProcessStatus(task, "");
	}

	/**
	 * 为Info*E Task添加部件发布状态值和部件发布时间值 bysunlaichao
	 * 
	 * @param task
	 * @param releaseTime
	 */
	public static void addPartProcessStatus(Task task, String releaseTime) {
		PDMIntegrationLogUtil.printLog(clazz, "addProcessStatus(Task task , String releaseTime) Starting ......");

		if (task != null) {
			try {
				task.removeParam(RELEASE_FLAG);
				task.removeParam(RELEASE_DATE);

				task.removeParam(RELEASE_FLAG_CRM);
				//update by sunlaichao 为部件的flag赋值,用于修改中间表flag标识,防止部件信息传到erp和sourcing -- 20191221
				//task.addParam(RELEASE_FLAG, IntegrationConstant.PDM_RELEASE_STATUS);
				task.addParam(RELEASE_FLAG, "Y");

				// add by ningxuge ,为flag_crm赋值
				task.addParam(RELEASE_FLAG_CRM, IntegrationConstant.PDM_RELEASE_STATUS);

				if (releaseTime == null || releaseTime.trim().equals("")) {
					releaseTime = CommonUtil.getCurrentTime();
				}

				PDMIntegrationLogUtil.printLog(clazz, "设置发布时间，releaseTime: " + releaseTime,
						IntegrationConstant.LOG_LEVEL_NORMAL);

				task.addParam(RELEASE_DATE, releaseTime);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addProcessStatus(Task task , String releaseTime) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addProcessStatus(Task task , String releaseTime) Finished ......");
			}
		}
	}

	/**
	 * 为Info*E Task添加发布状态值和发布时间值
	 * 
	 * @param task
	 * @param releaseTime
	 */
	public static void addProcessStatus(Task task, String releaseTime) {
		PDMIntegrationLogUtil.printLog(clazz, "addProcessStatus(Task task , String releaseTime) Starting ......");

		if (task != null) {
			try {
				task.removeParam(RELEASE_FLAG);
				task.removeParam(RELEASE_DATE);

				task.removeParam(RELEASE_FLAG_CRM);
				task.addParam(RELEASE_FLAG, IntegrationConstant.PDM_RELEASE_STATUS);

				// add by ningxuge ,为flag_crm赋值
				task.addParam(RELEASE_FLAG_CRM, IntegrationConstant.PDM_RELEASE_STATUS);

				if (releaseTime == null || releaseTime.trim().equals("")) {
					releaseTime = CommonUtil.getCurrentTime();
				}

				PDMIntegrationLogUtil.printLog(clazz, "设置发布时间，releaseTime: " + releaseTime,
						IntegrationConstant.LOG_LEVEL_NORMAL);

				task.addParam(RELEASE_DATE, releaseTime);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addProcessStatus(Task task , String releaseTime) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addProcessStatus(Task task , String releaseTime) Finished ......");
			}
		}
	}

	public static void updatePDMWritebackStatus(Task task) {
		PDMIntegrationLogUtil.printLog(clazz, "updatePDMWritebackStatus(Task task) Starting ......");

		if (task != null) {
			try {
				task.removeParam(PDM_WRITE_BACK_STATUS);
				task.addParam(PDM_WRITE_BACK_STATUS, IntegrationConstant.PDM_RELEASE_STATUS);
			} finally {
				PDMIntegrationLogUtil.printLog(clazz, "updatePDMWritebackStatus(Task task) Finished ......");
			}
		}
	}

	/**
	 * 为零部件查询添加条件判断
	 * 
	 * @param part
	 * @param task
	 */
	public static void addWhere(WTPart part, Task task) {
		PDMIntegrationLogUtil.printLog(clazz, "addWhere(WTPart part , Task task) Starting ......");

		if (task != null) {
			try {
				String where = "item_id='" + AttributeUtil.getAttribute(part, "number") + "' ";

				where = where + " And " + "pview='" + AttributeUtil.getAttribute(part, "view") + "' ";

				where = where + " And " + "major_version='" + AttributeUtil.getAttribute(part, "majorVersion") + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz, "addWhere(WTPart part , Task task) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz, "addWhere(WTPart part , Task task) Finished ......");
			}
		}
	}

	/**
	 * 为BOM结构查询添加条件判断
	 * 
	 * @param usageLink
	 * @param task
	 */
	public static void addWhere(WTPartUsageLink usageLink, Task task) {
		PDMIntegrationLogUtil.printLog(clazz, "addWhere( WTPartUsageLink usageLink , Task task ) Starting ......");

		if (task != null) {
			WTPart parent = usageLink.getUsedBy();
			WTPartMaster childMaster = usageLink.getUses();
			String lineNumber = AttributeUtil.getAttribute(usageLink, PartUsageLinkAttribute.LINE_NUMBER);

			addWhere(parent, childMaster, lineNumber, task);
		}

		PDMIntegrationLogUtil.printLog(clazz, "addWhere( WTPartUsageLink usageLink , Task task ) Finished ......");
	}

	/**
	 * 为BOM结构查询添加条件判断
	 * 
	 * @param parent
	 * @param child
	 * @param task
	 */
	public static void addWhere(WTPart parent, WTPartMaster child, String lineNumber, Task task) {
		PDMIntegrationLogUtil.printLog(clazz,
				"addWhere( WTPart parent , WTPartMaster child , Task task ) Starting ......");

		if (parent != null && child != null && task != null) {
			try {
				String where = "parent_item_id='" + AttributeUtil.getAttribute(parent, "number") + "' ";

				where = where + " And " + "parent_view='" + AttributeUtil.getAttribute(parent, "view") + "' ";

				where = where + " And " + "parent_major_version='" + AttributeUtil.getAttribute(parent, "majorVersion")
						+ "' ";

				where = where + " And " + "child_item_id='" + child.getNumber() + "' ";

				where = where + " And " + "line_num='" + lineNumber + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhere( WTPart parent , WTPartMaster child , Task task ) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhere( WTPart parent , WTPartMaster child , Task task ) Finished ......");
			}
		}
	}

	/**
	 * 为ECN查询添加条件判断
	 * 
	 * @param ecn
	 * @param task
	 */
	public static void addWhere(ChangeOrder2 ecn, Task task) {
		PDMIntegrationLogUtil.printLog(clazz, "addWhere(ChangeOrder2 ecn , Task task) Starting ......");

		if (task != null) {
			try {
				String where = "ecn_id='" + AttributeUtil.getAttribute(ecn, "number") + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz, "addWhere(ChangeOrder2 ecn , Task task) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz, "addWhere(ChangeOrder2 ecn , Task task) Finished ......");
			}
		}
	}

	/**
	 * 为替代料查询添加条件判断
	 * 
	 * @param material
	 * @param task
	 */
	public static void addWhere(AlternativeMaterial material, Task task) {
		PDMIntegrationLogUtil.printLog(clazz, "addWhere( AlternativeMaterial material , Task task) Starting ......");

		if (task != null) {
			try {
				String where = "parent_item='" + AttributeUtil.getAttribute(material, "parentNumber") + "' ";

				where = where + " And " + "parent_view='" + AttributeUtil.getAttribute(material, "parentView") + "' ";

				where = where + " And " + "child_item='" + AttributeUtil.getAttribute(material, "childNumber") + "' ";

				where = where + " And " + "substitute_item='"
						+ AttributeUtil.getAttribute(material, "replacePartNumber") + "' ";

				where = where + " And " + "PARENT_MAJOR_VERSION='"
						+ AttributeUtil.getAttribute(material, "majorVersion") + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhere( AlternativeMaterial material , Task task) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhere( AlternativeMaterial material , Task task) Finished ......");
			}
		}
	}

	/**
	 * 为零部件删除添加条件判断
	 * 
	 * @param part
	 * @param task
	 */
	public static void addWhereForDelete(WTPart part, Task task) {
		PDMIntegrationLogUtil.printLog(clazz, "addWhereForDelete(WTPart part , Task task) Starting ......");

		if (part != null && task != null) {
			try {
				String where = "item_id='" + AttributeUtil.getAttribute(part, "number") + "' ";

				where = where + " And " + "pview='" + AttributeUtil.getAttribute(part, "view") + "' ";

				where = where + " And " + "major_version='" + AttributeUtil.getAttribute(part, "majorVersion") + "' ";

				where = where + " And " + "pdm_write_back_status='" + IntegrationConstant.PDM_WRITE_BACK + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDelete(WTPart part , Task task) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz, "addWhereForDelete(WTPart part , Task task) Finished ......");
			}
		}
	}

	/**
	 * 为BOM结构关系删除添加条件判断
	 * 
	 * @param usageLink
	 * @param task
	 */
	public static void addWhereForDelete(WTPartUsageLink usageLink, Task task) {
		PDMIntegrationLogUtil.printLog(clazz,
				"addWhereForDelete( WTPartUsageLink usageLink , Task task ) Starting ......");

		if (usageLink != null && task != null) {
			try {
				WTPart parent = usageLink.getUsedBy();
				WTPartMaster childMaster = usageLink.getUses();
				String lineNumber = AttributeUtil.getAttribute(usageLink, PartUsageLinkAttribute.LINE_NUMBER);

				addWhereForDelete(parent, childMaster, lineNumber, task);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDelete( WTPartUsageLink usageLink , Task task ) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDelete( WTPartUsageLink usageLink , Task task ) Finished ......");
			}
		}
	}

	/**
	 * 为BOM结构关系删除添加条件判断
	 * 
	 * @param parent
	 * @param childMaster
	 * @param task
	 */
	public static void addWhereForDelete(WTPart parent, WTPartMaster childMaster, String lineNumber, Task task) {
		PDMIntegrationLogUtil.printLog(clazz,
				"addWhereForDelete( WTPart parent , WTPartMaster childMaster , Task task ) Starting ......");

		if (parent != null && childMaster != null && task != null) {
			try {
				String where = "parent_item_id='" + AttributeUtil.getAttribute(parent, "number") + "' ";

				where = where + " And " + "parent_view='" + AttributeUtil.getAttribute(parent, "view") + "' ";

				where = where + " And " + "parent_major_version='" + AttributeUtil.getAttribute(parent, "majorVersion")
						+ "' ";

				where = where + " And " + "child_item_id='" + childMaster.getNumber() + "' ";

				where = where + " And " + "line_num='" + lineNumber + "' ";

				where = where + " And " + "pdm_write_back_status='" + IntegrationConstant.PDM_WRITE_BACK + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDelete( WTPart parent , WTPartMaster childMaster , Task task ) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDelete( WTPart parent , WTPartMaster childMaster , Task task ) Finished ......");
			}
		}
	}

	/**
	 * 为ECN删除添加条件判断
	 * 
	 * @param ecn
	 * @param task
	 */
	public static void addWhereForDelete(ChangeOrder2 ecn, Task task) {
		PDMIntegrationLogUtil.printLog(clazz, "addWhereForDelete(ChangeOrder2 ecn , Task task) Starting ......");

		if (ecn != null && task != null) {
			try {

				String where = "ecn_id='" + AttributeUtil.getAttribute(ecn, "number") + "' ";
				where = where + " And " + "pdm_write_back_status='" + IntegrationConstant.PDM_WRITE_BACK + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDelete(ChangeOrder2 ecn , Task task) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDelete(ChangeOrder2 ecn , Task task) Finished ......");
			}
		}
	}

	/**
	 * 为替代料关系删除添加条件判断
	 * 
	 * @param material
	 * @param task
	 */
	public static void addWhereForDelete(AlternativeMaterial material, Task task) {
		PDMIntegrationLogUtil.printLog(clazz,
				"addWhereForDelete( AlternativeMaterial material , Task task ) Starting ......");

		if (material != null && task != null) {
			try {
				String where = "parent_item='" + AttributeUtil.getAttribute(material, "parentNumber") + "' ";

				where = where + " And " + "parent_view='" + AttributeUtil.getAttribute(material, "parentView") + "' ";

				where = where + " And " + "child_item='" + AttributeUtil.getAttribute(material, "childNumber") + "' ";

				where = where + " And " + "substitute_item='"
						+ AttributeUtil.getAttribute(material, "replacePartNumber") + "' ";

				where = where + " And " + "pdm_write_back_status='" + IntegrationConstant.PDM_WRITE_BACK + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDelete( AlternativeMaterial material , Task task ) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDelete( AlternativeMaterial material , Task task ) Finished ......");
			}
		}
	}

	/**
	 * add by 湃睿 ，将编译后的代码增加的部分进行补充 2017-01-13（ningxuge）
	 */
	public static void addWhereForDeleteByChild(WTPartUsageLink usageLink, Task task) {
		PDMIntegrationLogUtil.printLog(clazz,
				"addWhereForDeleteByChild( WTPartUsageLink usageLink , Task task ) Starting ......");

		if ((usageLink != null) && (task != null))
			try {
				String where = "parent_item='" + AttributeUtil.getAttribute(usageLink, "parentNumber") + "' ";

				where = where + " And " + "parent_view='" + AttributeUtil.getAttribute(usageLink, "parentView") + "' ";

				where = where + " And " + "child_item='" + AttributeUtil.getAttribute(usageLink, "childNumber") + "' ";

				where = where + " And " + "PARENT_MAJOR_VERSION='"
						+ AttributeUtil.getAttribute(usageLink, "parentMajorVersion") + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDeleteByChild( WTPartUsageLink usageLink , Task task ) Throws Exception ......", 3);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDeleteByChild( WTPartUsageLink usageLink , Task task ) Finished ......");
			}
	}

	public static void addWhereForDeleteByChild(WTPartMaster partMaster, Task task) {
		PDMIntegrationLogUtil.printLog(clazz,
				"addWhereForDeleteByChild( WTPartMaster partMaster , Task task ) Starting ......");

		if ((partMaster != null) && (task != null))
			try {
				String where = "parent_item='noValue' ";

				where = where + " And " + "parent_view='" + "noValue" + "' ";

				where = where + " And " + "child_item='" + partMaster.getNumber() + "' ";

				PDMIntegrationLogUtil.printLog(clazz, "where is " + where);

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDeleteByChild( WTPartMaster partMaster , Task task ) Throws Exception ......", 3);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForDeleteByChild( WTPartMaster partMaster , Task task ) Finished ......");
			}
	}

	/**
	 * 为task添加ECN信息
	 * 
	 * @param task
	 * @param ecnNumber
	 */
	public static void addEcnNumber(Task task, String ecnNumber) {
		PDMIntegrationLogUtil.printLog(clazz, "addEcnNumber(Task task , String ecnNumber) Starting ......");

		if (task != null) {
			if (ecnNumber == null || ecnNumber.trim().equals("")) {
				ecnNumber = "";
			}

			try {
				task.removeParam("ecn_number");

				PDMIntegrationLogUtil.printLog(clazz, "ecnNumber = " + ecnNumber);

				task.addParam("ecn_number", ecnNumber);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addEcnNumber(Task task , String ecnNumber) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz, "addEcnNumber(Task task , String ecnNumber) Finished ......");
			}
		}
	}

	public static void addWhereForRemoveRecordByParent(WTPart part, Task task) {
		PDMIntegrationLogUtil.printLog(clazz,
				"addWhereForRemoveRecordByParent(WTPart part, Task task) Starting ......");

		if (part != null && task != null) {
			try {
				String where = "parent_item_id='" + AttributeUtil.getAttribute(part, "number") + "' ";

				where = where + " And " + "parent_view='" + AttributeUtil.getAttribute(part, "view") + "' ";

				where = where + " And " + "parent_major_version='" + AttributeUtil.getAttribute(part, "majorVersion")
						+ "' ";

				task.addParam("WHERE", where);
			} catch (Exception e) {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForRemoveRecordByParent(WTPart part, Task task) Throws Exception ......",
						IntegrationConstant.LOG_LEVEL_ERROR);
				PDMIntegrationLogUtil.printLog(clazz, e.getMessage(), IntegrationConstant.LOG_LEVEL_ERROR);
				e.printStackTrace();
			} finally {
				PDMIntegrationLogUtil.printLog(clazz,
						"addWhereForRemoveRecordByParent(WTPart part, Task task) Finished ......");
			}
		}
	}

	/**
	 * 判断Group中是否有返回对象
	 * 
	 * @param group
	 * @return
	 */
	public static boolean hasObject(Group group) {
		PDMIntegrationLogUtil.printLog(clazz, "hasObject( Group group) Starting ......");

		boolean hasObject = false;

		if (group != null && group.getElementCount() > 0) {
			hasObject = true;
		}

		PDMIntegrationLogUtil.printLog(clazz, "hasObject = " + hasObject);

		PDMIntegrationLogUtil.printLog(clazz, "hasObject( Group group) Finished ......");

		return hasObject;
	}

	/**
	 * 获取Task的参数列表
	 * 
	 * @param task
	 * @return
	 */
	public static String getTaskParams(Task task) {
		PDMIntegrationLogUtil.printLog(clazz, "getTaskParams(Task task) Starting ......");

		StringBuffer buffer = new StringBuffer("\n");

		if (task != null) {
			buffer.append("********* Start Print Task Params  *********\n");

			Enumeration<?> paramNames = task.getParamNames();

			if (paramNames != null) {
				int i = 0;

				while (paramNames.hasMoreElements()) {
					i++;
					String paramName = (String) paramNames.nextElement();
					String paramValue = "";

					if (paramName != null) {
						paramValue = (String) task.getParam(paramName);
					} else {
						paramName = "";
						paramValue = "";
					}

					buffer.append(i);
					buffer.append(" : ");
					buffer.append("[");
					buffer.append(paramName);
					buffer.append("=====>");
					buffer.append(paramValue);
					buffer.append("]\n");
				}
			}

			buffer.append("********** End Print Task Params  **********\n");
		} else {
			buffer.append("getTaskParams(Task task), task == null\n");
		}

		PDMIntegrationLogUtil.printLog(clazz, "getTaskParams(Task task) Finished ......");

		return buffer.toString();
	}
}
